package com.lwj.liwanjia.presenter;

import com.lwj.liwanjia.bean.AddAdressBean;
import com.lwj.liwanjia.impl.AddAddressView;
import com.lwj.liwanjia.model.AddAdreessModel;

import java.util.Map;

import rx.Subscriber;

/**
 * Created by Administrator on 2017/10/10.
 */

public class AddAddressPresenter {
    private AddAddressView addAddressView;
    private AddAdreessModel addAdreessModel;

    public AddAddressPresenter(AddAddressView addAddressView) {
        this.addAddressView = addAddressView;
        addAdreessModel = new AddAdreessModel();
    }

    public void addAddress(Map<String, Object> map) {
        if (addAddressView != null) {
            addAdreessModel.addAddress(map, new Subscriber<AddAdressBean>() {
                @Override
                public void onCompleted() {
                }

                @Override
                public void onError(Throwable e) {
                    addAddressView.showError((Exception) e);
                }

                @Override
                public void onNext(AddAdressBean addAdressBean) {
                    addAddressView.addAddress(addAdressBean);
                }
            });
        }
    }
}
